﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Dapper;
using Core;
using System.Threading;
using System.Net;

namespace DAL
{
    public class ReTeacherRecordDAL : SyncBase<Model.ReTeacherRecord>
    {
        static ReTeacherRecordDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReTeacherRecordDAL.addSQL = @"insert into ReTeacherRecord(TeacherID,LessionID,ClassID,StartTime,TimePoint,TactionCode,TactionResource,TactionContent)
                                                            values (@TeacherID,@LessionID,@ClassID,@StartTime,@TimePoint,@TactionCode,@TactionResource,@TactionContent);";
            ReTeacherRecordDAL.tbName = "ReTeacherRecord";
            ReTeacherRecordDAL.remoteUrl = "/Ayyfford/AddTeacherRecord";
            ReTeacherRecordDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7}),",
                            t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.ClassID.NullNumber(), t.StartTime.NullDate(), t.TimePoint.NullNumber(), t.TactionCode.NullString(), t.TactionResource.NullNumber(), t.TactionContent.NullNumber());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReTeacherRecord t)
        {
            SyncBase<Model.ReTeacherRecord>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReTeacherRecord>.AsyncData();
        }
    }
}
